package com.selenium;

import com.alibaba.fastjson.JSONObject;
import com.selenium.bean.FetchCorpVO;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.chrome.ChromeOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class Config {

    Logger log = LoggerFactory.getLogger(Config.class);

    public final static String path = "C:/config.txt";

    public final static String imgPath = "G:/qrCode";

    public  static String driverPath = "C:/Users/domains90/AppData/Local/Google/Chrome/Application/chromedriver.exe";

    public final static ChromeOptions op = new ChromeOptions().addArguments("--remote-allow-origins=*");

    static {
        System.err.println("读取配置文件");
        try (InputStreamReader read = new InputStreamReader(new FileInputStream(path), "UTF-8");){
            // 考虑到编码格式
            BufferedReader bufferedReader = new BufferedReader(read);
            String lineTxt;
            StringBuffer buf = new StringBuffer();
            while ((lineTxt = bufferedReader.readLine()) != null) {
                buf.append(lineTxt);
            }
            JSONObject json = JSONObject.parseObject(buf.toString());
            driverPath = json.getString("driverPath");
            System.err.println("配置文件info:"+json);
        }catch (Exception e) {
            System.err.println("读取配置文件失败");
        }
    }



}
